/*****************************************************************************/
/*                                                                           */
/*    Domino Operation System Kernel Module                                  */
/*                                                                           */
/*    Copyright (C) 2007 Laszlo Arvai                                        */
/*                                                                           */
/*    ------------------------------------------------------------------     */
/*    krnlCAN.c - Controller Area Network functions                          */
/*****************************************************************************/

///////////////////////////////////////////////////////////////////////////////
// Includes
#include "krnlCAN.h"
#include "krnlCANMessageMap.h"

///////////////////////////////////////////////////////////////////////////////
// Idle Handler
void krnlCANIdleHandler(void)
{
	krnlMessage* message;
	krnlCANMessage can_message;
	dosWord id;
	dosByte i;

//**test
//return;

	if( krnlCANIsMessageAvailable() )
	{
    message = krnlAllocateMessage();

    if( message != DOS_NULL )
    {
			// ge message
			krnlCANGetMessage( &can_message );

			// generate id
			id = krnlCANMessageToDominoMessageId( &can_message );

			message->Id = id;

			// copy databytes
			for( i = 0; i < krnlMESSAGE_DATA_LENGTH; i++ )
				message->Data[i] = can_message.Data[i];
   	}
	}
}

